<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="resources/js/jquery-1.7.2.min.js"></script>
<style type="text/css">
*{
	margin:0;
	padding: 0;
}
body{
	background: #e3e5e5;
}
h1{
	font-family: Constantia, serif;
	font-size:  45px;
	color: #333;
	text-shadow: -1px 1px 2px #000;
	text-align: center;
	margin-top: 20px;
}
#Parallax{
	background: #000;
	width: 100%;
	height: 400px;
	margin-top: 20px;
	overflow: hidden;
	position: relative;
}
#Parallax img{
	position: absolute;
	top:0;
	left:0;
}
</style>
</head>
<body>
<h1>Parallax Box</h1>
<div id="Parallax">
<img src="resources/img/layer1.png">
<img src="resources/img/layer2.png">
<img src="resources/img/cbnu3.png">
</div>

	<script type="text/javascript">
			$(function(){

				$('#Parallax').mousemove(
					function(e){
						
						var offset = $(this).offset();

						var xP = e.pageX - offset.left;
						var yP = e.pageY - offset.top;

						var XPercent = Math.round(xP / $(this).width() * 100);
						var YPercent = Math.round(yP / $(this).height() * 100);


						$(this).children('img').each(		
							function(){
								var diffX = $('#Parallax').width() - $(this).width();
								var diffY = $('#Parallax').height() - $(this).height();

								var myX = diffX * (XPercent / 100); 
								var myY = diffY * (YPercent / 100);

								$(this).animate({left: myX, top: myY},{duration: 50, queue: false, easing: 'linear'});
							}
						);

					}
				);
			});
		</script>
</body>
</html>